package com.cloudcc.mobile.weight.webview;

import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebView;

import com.cloudcc.mobile.util.DialogUtils;
import com.cloudcc.mobile.util.DialogUtils.OnDoClickListener;

/** 
* @Description: WebChromeClient 自定义客户端
* @author wangzhiqiang
* @date 2015-12-4 上午11:12:31 
*  
*/
public class CloudccWebChromeClient extends WebChromeClient {

	@Override
	public boolean onJsAlert(WebView view, String url, String message,
			final JsResult result) {
		DialogUtils dialogutils = new DialogUtils(view.getContext());
		dialogutils.showUpdateDialog(view.getContext(), "网页提示", message);
		dialogutils.setOnDoClicktListener(new OnDoClickListener() {
			@Override
			public void confirm() {
				result.confirm();
			}

			@Override
			public void cancel() {
				result.cancel();
			}
		});
		return true;
	}
	@Override
	public boolean onJsConfirm(WebView view, String url, String message,
			final JsResult result) {
		DialogUtils dialogutils = new DialogUtils(view.getContext());
		dialogutils.showUpdateDialog(view.getContext(), "网页提示", message);
		dialogutils.setOnDoClicktListener(new OnDoClickListener() {
			@Override
			public void confirm() {
				result.confirm();
			}

			@Override
			public void cancel() {
				result.cancel();
			}
		});
		return true;
	}
}
